package com.example.android.BluetoothChat.util.provider.player.impl;

import android.content.Context;

import com.example.android.BluetoothChat.bean.Game;
import com.example.android.BluetoothChat.bean.GameRequestResponse;
import com.example.android.BluetoothChat.bean.Player;

public class MockPlayerProviderImpl extends APlayerProviderImpl {
	@Override
	public void findPlayersNearby(Context parContext) {

		new Thread() {

			@Override
			public void run() {
				try {

					Player locPlayer = new Player();
					locPlayer.setName("Fake : TheoHTC");
					locPlayer.setBluetoothMacAddress("fake_bluetooth_address1");
					Thread.sleep(300);
					fireNewPlayerFound(locPlayer);
					locPlayer = new Player();
					locPlayer.setName("Fake : HabibGalaxyS");
					locPlayer.setBluetoothMacAddress("fake_bluetooth_address2");
					Thread.sleep(200);
					fireNewPlayerFound(locPlayer);
					locPlayer = new Player();
					locPlayer.setName("Fake : PGHTC");
					locPlayer.setBluetoothMacAddress("fake_bluetooth_address3");
					Thread.sleep(600);
					fireNewPlayerFound(locPlayer);
					locPlayer = new Player();
					locPlayer.setName("Fake : GiorgioLG");
					locPlayer.setBluetoothMacAddress("fake_bluetooth_address4");
					Thread.sleep(1000);
					fireNewPlayerFound(locPlayer);
				} catch (InterruptedException e){
					e.printStackTrace();
				}

			}
		}.start();

	}

	@Override
	public void askPlayerToPlay(final Player parPlayer,final Game parGame) {
		new Runnable() {

			@Override
			public void run() {
				try {
					wait(4000);
					GameRequestResponse locGameRequestResponse = new GameRequestResponse();
					locGameRequestResponse.setGame(parGame);
					locGameRequestResponse.setPlayer(parPlayer);
					locGameRequestResponse.setLetsPlay(Math.random() > 0.5);
					handleResponseForPlaying(locGameRequestResponse);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}

			}
		};

	}


	@Override
	public void handleResponseForPlaying(GameRequestResponse parGameRequestResponse) {
		// TODO Auto-generated method stub

	}
}
